.class public Lcom/google/android/exoplayer/audio/c;
.super Ljava/lang/Object;
.source "Resampler.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/google/android/exoplayer/audio/c$b;
    }
.end annotation


# instance fields
.field private a:I

.field private b:[Lcom/google/android/exoplayer/audio/c$b;

.field private c:[S

.field private d:[S


# direct methods
.method static constructor <clinit>()V
    .locals 0

    return-void
.end method

.method public constructor <init>(IIII)V
    .locals 1

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 2
    iput-object v0, p0, Lcom/google/android/exoplayer/audio/c;->c:[S

    .line 3
    iput-object v0, p0, Lcom/google/android/exoplayer/audio/c;->d:[S

    if-lez p1, :cond_0

    if-lez p2, :cond_0

    if-lez p3, :cond_0

    .line 4
    invoke-direct {p0, p1, p2, p3, p4}, Lcom/google/android/exoplayer/audio/c;->a(IIII)V

    return-void

    .line 5
    :cond_0
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string p2, "inSampleRate <= 0 || outSampleRate <= 0 || inChannels <= 0"

    invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method private static a([S[SD[II)I
    .locals 7

    const-wide/high16 v0, 0x3ff0000000000000L    # 1.0

    div-double/2addr v0, p2

    const-wide/high16 p2, 0x40e0000000000000L    # 32768.0

    mul-double v0, v0, p2

    const-wide/high16 p2, 0x3fe0000000000000L    # 0.5

    add-double/2addr v0, p2

    double-to-int p2, v0

    const/4 p3, 0x0

    .line 73
    aget v0, p4, p3

    const v1, 0x8000

    mul-int p5, p5, v1

    add-int/2addr v0, p5

    const/4 p5, 0x0

    .line 74
    :goto_0
    aget v2, p4, p3

    if-ge v2, v0, :cond_0

    .line 75
    aget v2, p4, p3

    and-int/lit16 v2, v2, 0x7fff

    int-to-short v2, v2

    .line 76
    aget v3, p4, p3

    const/16 v4, 0xf

    shr-int/2addr v3, v4

    .line 77
    aget-short v5, p0, v3

    add-int/lit8 v3, v3, 0x1

    .line 78
    aget-short v3, p0, v3

    sub-int v6, v1, v2

    mul-int v5, v5, v6

    mul-int v3, v3, v2

    add-int/lit8 v2, p5, 0x1

    add-int/2addr v5, v3

    .line 79
    invoke-static {v5, v4}, Lcom/google/android/exoplayer/audio/c;->a(II)S

    move-result v3

    aput-short v3, p1, p5

    .line 80
    aget p5, p4, p3

    add-int/2addr p5, p2

    aput p5, p4, p3

    move p5, v2

    goto :goto_0

    :cond_0
    return p5
.end method

.method private static a(II)S
    .locals 2

    add-int/lit8 v0, p1, -0x1

    const/4 v1, 0x1

    shl-int v0, v1, v0

    add-int/2addr p0, v0

    shr-int/2addr p0, p1

    const/16 p1, 0x7fff

    if-le p0, p1, :cond_0

    const/16 p0, -0x8000

    :cond_0
    int-to-short p0, p0

    return p0
.end method

.method private a(IIII)V
    .locals 8

    .line 1
    iput p3, p0, Lcom/google/android/exoplayer/audio/c;->a:I

    .line 2
    new-array v0, p3, [Lcom/google/android/exoplayer/audio/c$b;

    iput-object v0, p0, Lcom/google/android/exoplayer/audio/c;->b:[Lcom/google/android/exoplayer/audio/c$b;

    const/4 v0, 0x0

    const/4 v1, 0x0

    .line 3
    :goto_0
    iget v2, p0, Lcom/google/android/exoplayer/audio/c;->a:I

    if-ge v1, v2, :cond_1

    .line 4
    new-instance v2, Lcom/google/android/exoplayer/audio/c$b;

    const/4 v3, 0x0

    invoke-direct {v2, p0, v3}, Lcom/google/android/exoplayer/audio/c$b;-><init>(Lcom/google/android/exoplayer/audio/c;Lcom/google/android/exoplayer/audio/c$a;)V

    int-to-double v3, p2

    int-to-double v5, p1

    .line 5
    invoke-static {v3, v4}, Ljava/lang/Double;->isNaN(D)Z

    invoke-static {v5, v6}, Ljava/lang/Double;->isNaN(D)Z

    div-double/2addr v3, v5

    iput-wide v3, v2, Lcom/google/android/exoplayer/audio/c$b;->a:D

    const/16 v3, 0xa

    .line 6
    iput v3, v2, Lcom/google/android/exoplayer/audio/c$b;->f:I

    .line 7
    iput v3, v2, Lcom/google/android/exoplayer/audio/c$b;->c:I

    .line 8
    iput v3, v2, Lcom/google/android/exoplayer/audio/c$b;->e:I

    const/4 v4, 0x1

    new-array v4, v4, [I

    shl-int/lit8 v3, v3, 0xf

    aput v3, v4, v0

    .line 9
    iput-object v4, v2, Lcom/google/android/exoplayer/audio/c$b;->b:[I

    if-lez p4, :cond_0

    .line 10
    div-int/lit8 v3, p4, 0x2

    div-int/2addr v3, p3

    goto :goto_1

    :cond_0
    const/16 v3, 0x1000

    :goto_1
    iput v3, v2, Lcom/google/android/exoplayer/audio/c$b;->h:I

    int-to-double v4, v3

    .line 11
    iget-wide v6, v2, Lcom/google/android/exoplayer/audio/c$b;->a:D

    invoke-static {v4, v5}, Ljava/lang/Double;->isNaN(D)Z

    mul-double v4, v4, v6

    const-wide/high16 v6, 0x4000000000000000L    # 2.0

    add-double/2addr v4, v6

    double-to-int v4, v4

    iput v4, v2, Lcom/google/android/exoplayer/audio/c$b;->i:I

    .line 12
    iget v5, v2, Lcom/google/android/exoplayer/audio/c$b;->f:I

    add-int/2addr v3, v5

    new-array v3, v3, [S

    iput-object v3, v2, Lcom/google/android/exoplayer/audio/c$b;->j:[S

    .line 13
    new-array v4, v4, [S

    iput-object v4, v2, Lcom/google/android/exoplayer/audio/c$b;->k:[S

    .line 14
    invoke-static {v3, v0}, Ljava/util/Arrays;->fill([SS)V

    .line 15
    iget-object v3, p0, Lcom/google/android/exoplayer/audio/c;->b:[Lcom/google/android/exoplayer/audio/c$b;

    aput-object v2, v3, v1

    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    :cond_1
    return-void
.end method


# virtual methods
.method public a(I)I
    .locals 6

    .line 16
    iget-object v0, p0, Lcom/google/android/exoplayer/audio/c;->b:[Lcom/google/android/exoplayer/audio/c$b;

    const/4 v1, -0x1

    if-nez v0, :cond_0

    return v1

    :cond_0
    const/4 v2, 0x0

    .line 17
    aget-object v0, v0, v2

    iget-wide v2, v0, Lcom/google/android/exoplayer/audio/c$b;->a:D

    .line 18
    iget v0, p0, Lcom/google/android/exoplayer/audio/c;->a:I

    mul-int/lit8 v0, v0, 0x2

    int-to-double v4, p1

    .line 19
    invoke-static {v4, v5}, Ljava/lang/Double;->isNaN(D)Z

    mul-double v4, v4, v2

    double-to-int p1, v4

    add-int/lit8 v2, v0, -0x1

    add-int/2addr p1, v2

    xor-int/2addr v1, v2

    and-int/2addr p1, v1

    mul-int/lit8 v0, v0, 0x4

    add-int/2addr p1, v0

    return p1
.end method

.method public a(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;IZ)I
    .locals 2

    if-eqz p1, :cond_6

    if-eqz p2, :cond_6

    .line 20
    invoke-virtual {p1}, Ljava/nio/ByteBuffer;->remaining()I

    move-result v0

    if-lt v0, p3, :cond_5

    .line 21
    invoke-virtual {p2}, Ljava/nio/ByteBuffer;->isReadOnly()Z

    move-result v0

    if-nez v0, :cond_4

    .line 22
    invoke-virtual {p1}, Ljava/nio/ByteBuffer;->position()I

    move-result v0

    add-int/2addr v0, p3

    invoke-virtual {p1, v0}, Ljava/nio/ByteBuffer;->limit(I)Ljava/nio/Buffer;

    .line 23
    sget-object v0, Ljava/nio/ByteOrder;->LITTLE_ENDIAN:Ljava/nio/ByteOrder;

    invoke-virtual {p1, v0}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;

    move-result-object p1

    invoke-virtual {p1}, Ljava/nio/ByteBuffer;->asShortBuffer()Ljava/nio/ShortBuffer;

    move-result-object p1

    .line 24
    iget-object v0, p0, Lcom/google/android/exoplayer/audio/c;->c:[S

    if-eqz v0, :cond_0

    array-length v0, v0

    div-int/lit8 v1, p3, 0x2

    if-ge v0, v1, :cond_1

    .line 25
    :cond_0
    div-int/lit8 v0, p3, 0x2

    new-array v0, v0, [S

    iput-object v0, p0, Lcom/google/android/exoplayer/audio/c;->c:[S

    .line 26
    :cond_1
    iget-object v0, p0, Lcom/google/android/exoplayer/audio/c;->c:[S

    div-int/lit8 p3, p3, 0x2

    const/4 v1, 0x0

    invoke-virtual {p1, v0, v1, p3}, Ljava/nio/ShortBuffer;->get([SII)Ljava/nio/ShortBuffer;

    .line 27
    iget-object p1, p0, Lcom/google/android/exoplayer/audio/c;->d:[S

    if-eqz p1, :cond_2

    array-length p1, p1

    invoke-virtual {p2}, Ljava/nio/ByteBuffer;->capacity()I

    move-result v0

    div-int/lit8 v0, v0, 0x2

    if-ge p1, v0, :cond_3

    .line 28
    :cond_2
    invoke-virtual {p2}, Ljava/nio/ByteBuffer;->capacity()I

    move-result p1

    div-int/lit8 p1, p1, 0x2

    new-array p1, p1, [S

    iput-object p1, p0, Lcom/google/android/exoplayer/audio/c;->d:[S

    .line 29
    :cond_3
    iget-object p1, p0, Lcom/google/android/exoplayer/audio/c;->c:[S

    iget-object v0, p0, Lcom/google/android/exoplayer/audio/c;->d:[S

    invoke-virtual {p0, p1, v0, p3, p4}, Lcom/google/android/exoplayer/audio/c;->a([S[SIZ)I

    move-result p1

    .line 30
    invoke-virtual {p2}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;

    .line 31
    sget-object p3, Ljava/nio/ByteOrder;->LITTLE_ENDIAN:Ljava/nio/ByteOrder;

    invoke-virtual {p2, p3}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;

    move-result-object p3

    invoke-virtual {p3}, Ljava/nio/ByteBuffer;->asShortBuffer()Ljava/nio/ShortBuffer;

    move-result-object p3

    .line 32
    iget-object p4, p0, Lcom/google/android/exoplayer/audio/c;->d:[S

    invoke-virtual {p3, p4, v1, p1}, Ljava/nio/ShortBuffer;->put([SII)Ljava/nio/ShortBuffer;

    mul-int/lit8 p1, p1, 0x2

    .line 33
    invoke-virtual {p2, p1}, Ljava/nio/ByteBuffer;->limit(I)Ljava/nio/Buffer;

    return p1

    .line 34
    :cond_4
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string p2, "outBuf is read only"

    invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1

    .line 35
    :cond_5
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string p2, "inBuf.remaining() < inBufSize"

    invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1

    .line 36
    :cond_6
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string p2, "inBuf == null || outBuf == null"

    invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public a([S[SIZ)I
    .locals 18

    move-object/from16 v0, p0

    move-object/from16 v1, p2

    .line 37
    iget-object v2, v0, Lcom/google/android/exoplayer/audio/c;->b:[Lcom/google/android/exoplayer/audio/c$b;

    if-nez v2, :cond_0

    const/4 v1, -0x1

    return v1

    .line 38
    :cond_0
    iget v2, v0, Lcom/google/android/exoplayer/audio/c;->a:I

    div-int v3, p3, v2

    .line 39
    array-length v4, v1

    div-int/2addr v4, v2

    const/4 v2, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    .line 40
    :goto_0
    iget v7, v0, Lcom/google/android/exoplayer/audio/c;->a:I

    if-ge v5, v7, :cond_c

    .line 41
    iget-object v7, v0, Lcom/google/android/exoplayer/audio/c;->b:[Lcom/google/android/exoplayer/audio/c$b;

    aget-object v7, v7, v5

    .line 42
    iput v2, v7, Lcom/google/android/exoplayer/audio/c$b;->g:I

    const/4 v8, 0x0

    .line 43
    :cond_1
    iget v9, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    if-lez v9, :cond_3

    .line 44
    invoke-static {v4, v9}, Ljava/lang/Math;->min(II)I

    move-result v9

    const/4 v10, 0x0

    :goto_1
    if-ge v10, v9, :cond_2

    .line 45
    iget v11, v0, Lcom/google/android/exoplayer/audio/c;->a:I

    add-int v12, v8, v10

    mul-int v11, v11, v12

    add-int/2addr v11, v5

    iget-object v12, v7, Lcom/google/android/exoplayer/audio/c$b;->k:[S

    aget-short v12, v12, v10

    aput-short v12, v1, v11

    add-int/lit8 v10, v10, 0x1

    goto :goto_1

    :cond_2
    add-int/2addr v8, v9

    .line 46
    iget-object v10, v7, Lcom/google/android/exoplayer/audio/c$b;->k:[S

    iget v11, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    sub-int/2addr v11, v9

    invoke-static {v10, v9, v10, v2, v11}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 47
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    sub-int/2addr v10, v9

    iput v10, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    goto/16 :goto_5

    .line 48
    :cond_3
    iget v9, v7, Lcom/google/android/exoplayer/audio/c$b;->h:I

    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    sub-int/2addr v9, v10

    .line 49
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->g:I

    sub-int v11, v3, v10

    if-lt v9, v11, :cond_4

    sub-int v9, v3, v10

    :cond_4
    const/4 v10, 0x0

    :goto_2
    if-ge v10, v9, :cond_5

    .line 50
    iget-object v11, v7, Lcom/google/android/exoplayer/audio/c$b;->j:[S

    iget v12, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    add-int/2addr v12, v10

    iget v13, v0, Lcom/google/android/exoplayer/audio/c;->a:I

    iget v14, v7, Lcom/google/android/exoplayer/audio/c$b;->g:I

    add-int/2addr v14, v10

    mul-int v13, v13, v14

    add-int/2addr v13, v5

    aget-short v13, p1, v13

    aput-short v13, v11, v12

    add-int/lit8 v10, v10, 0x1

    goto :goto_2

    .line 51
    :cond_5
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->g:I

    add-int/2addr v10, v9

    iput v10, v7, Lcom/google/android/exoplayer/audio/c$b;->g:I

    .line 52
    iget v11, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    add-int/2addr v11, v9

    iput v11, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    if-eqz p4, :cond_6

    if-ne v10, v3, :cond_6

    .line 53
    iget v9, v7, Lcom/google/android/exoplayer/audio/c$b;->f:I

    sub-int/2addr v11, v9

    const/4 v9, 0x0

    .line 54
    :goto_3
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->f:I

    if-ge v9, v10, :cond_7

    .line 55
    iget-object v10, v7, Lcom/google/android/exoplayer/audio/c$b;->j:[S

    iget v12, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    add-int/2addr v12, v9

    aput-short v2, v10, v12

    add-int/lit8 v9, v9, 0x1

    goto :goto_3

    .line 56
    :cond_6
    iget v9, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->f:I

    mul-int/lit8 v10, v10, 0x2

    sub-int v11, v9, v10

    :cond_7
    if-gtz v11, :cond_8

    goto/16 :goto_5

    .line 57
    :cond_8
    iget-object v12, v7, Lcom/google/android/exoplayer/audio/c$b;->j:[S

    iget-object v13, v7, Lcom/google/android/exoplayer/audio/c$b;->k:[S

    iget-wide v14, v7, Lcom/google/android/exoplayer/audio/c$b;->a:D

    iget-object v9, v7, Lcom/google/android/exoplayer/audio/c$b;->b:[I

    move-object/from16 v16, v9

    move/from16 v17, v11

    invoke-static/range {v12 .. v17}, Lcom/google/android/exoplayer/audio/c;->a([S[SD[II)I

    move-result v9

    .line 58
    iget-object v10, v7, Lcom/google/android/exoplayer/audio/c$b;->b:[I

    aget v12, v10, v2

    shl-int/lit8 v13, v11, 0xf

    sub-int/2addr v12, v13

    aput v12, v10, v2

    .line 59
    iget v12, v7, Lcom/google/android/exoplayer/audio/c$b;->c:I

    add-int/2addr v12, v11

    iput v12, v7, Lcom/google/android/exoplayer/audio/c$b;->c:I

    .line 60
    aget v11, v10, v2

    shr-int/lit8 v11, v11, 0xf

    iget v13, v7, Lcom/google/android/exoplayer/audio/c$b;->f:I

    sub-int/2addr v11, v13

    if-lez v11, :cond_9

    .line 61
    aget v13, v10, v2

    shl-int/lit8 v14, v11, 0xf

    sub-int/2addr v13, v14

    aput v13, v10, v2

    add-int/2addr v12, v11

    .line 62
    iput v12, v7, Lcom/google/android/exoplayer/audio/c$b;->c:I

    .line 63
    :cond_9
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    iget v11, v7, Lcom/google/android/exoplayer/audio/c$b;->c:I

    iget v12, v7, Lcom/google/android/exoplayer/audio/c$b;->f:I

    sub-int v13, v11, v12

    sub-int/2addr v10, v13

    .line 64
    iget-object v13, v7, Lcom/google/android/exoplayer/audio/c$b;->j:[S

    sub-int/2addr v11, v12

    invoke-static {v13, v11, v13, v2, v10}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 65
    iput v10, v7, Lcom/google/android/exoplayer/audio/c$b;->e:I

    .line 66
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->f:I

    iput v10, v7, Lcom/google/android/exoplayer/audio/c$b;->c:I

    .line 67
    iput v9, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    if-lez v9, :cond_b

    sub-int v10, v4, v8

    if-lez v10, :cond_b

    .line 68
    invoke-static {v10, v9}, Ljava/lang/Math;->min(II)I

    move-result v9

    const/4 v10, 0x0

    :goto_4
    if-ge v10, v9, :cond_a

    .line 69
    iget v11, v0, Lcom/google/android/exoplayer/audio/c;->a:I

    add-int v12, v8, v10

    mul-int v11, v11, v12

    add-int/2addr v11, v5

    iget-object v12, v7, Lcom/google/android/exoplayer/audio/c$b;->k:[S

    aget-short v12, v12, v10

    aput-short v12, v1, v11

    add-int/lit8 v10, v10, 0x1

    goto :goto_4

    :cond_a
    add-int/2addr v8, v9

    .line 70
    iget-object v10, v7, Lcom/google/android/exoplayer/audio/c$b;->k:[S

    iget v11, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    sub-int/2addr v11, v9

    invoke-static {v10, v9, v10, v2, v11}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 71
    iget v10, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    sub-int/2addr v10, v9

    iput v10, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    .line 72
    :cond_b
    iget v9, v7, Lcom/google/android/exoplayer/audio/c$b;->d:I

    if-lez v9, :cond_1

    :goto_5
    add-int/2addr v6, v8

    add-int/lit8 v5, v5, 0x1

    goto/16 :goto_0

    :cond_c
    return v6
.end method
